<!DOCTYPE html>
<html ng-app="com.feng" >
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>对账工作台</title>
    <link href="vendor/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link href="css/index.css" rel="stylesheet">
</head>
<body  ng-controller="billCtl"  ng-cloak>
    <div id="container">
        <div id="page">
            <h5 class="text-right"><label class="mr5">欢迎您！{{admin.account}}</label>
                <a href="javaScript:void(0)" ng-click="showPasswordModal()" class="mr5">修改密码</a>
                <a href="/adminUser/logout">退出</a></h5>
            <h1 class="text-center">对账工作台</h1>
            <uib-tabset >
                <uib-tab heading="台帐模式" ng-if="hasAccess('mainTab')">
                    <div class="navbar-form clearfix">
                        <div class="text-right" >
                            <button class="btn btn-success" ng-if="hasAccess('main_upload_sub')" ng-click="compareExcel()" ><i class="glyphicon glyphicon-file mr5"></i>上传&比较账单</button>
                            <button class="btn btn-warning" ng-if="hasAccess('main_upload_main')" ng-click="uploadExcel()" ><i class="glyphicon glyphicon-file mr5"></i>台帐导入</button>
                        </div>
                        <div class="form-inline" style="margin-top: 5px">
                            <div class="form-group">
                                <label>保险公司</label>
                                <input type="text" ng-model="search.company" class="form-control" style="width:120px;"/>
                            </div>
                            <div class="form-group">
                                <label>保单号</label>
                                <input type="text" ng-model="search.no" class="form-control" style="width:200px;"/>
                            </div>
                            <div class="form-group">
                                <label>被保险人</label>
                                <input type="text" ng-model="search.name" class="form-control" style="width:120px;"/>
                            </div>
                            <div class="form-group">
                                <label>车牌</label>
                                <input type="text" ng-model="search.licensePlate" class="form-control" style="width:120px;"/>
                            </div>
                            <button class="btn btn-primary" ng-if="hasAccess('query')" ng-click="find(1)" >查询</button>
                            <button class="btn btn-info" ng-if="hasAccess('add')" ng-click="addRec()" >新增</button>
                            <button class="btn btn-danger" ng-if="hasAccess('clear')" ng-click="truncate()" >清空</button>
                        </div>

                    </div>
                    <table class="table table-bordered table-striped table-hover" >
                        <thead class="title">
                        <tr>
                            <th class="text-center" style="width:30px">NO</th>
                            <th style="width:85px">保险公司</th>
                            <th style="width:135px">被保险人</th>
                            <th style="width:95px">车牌</th>
                            <th >保单号<order field="insuranceNo" class="pull-right mr5 pointer"></order></th>
                            <th style="width:110px">金额<order field="amount" class="pull-right mr5 pointer"></order></th>
                            <th style="width:100px">导入者</th>
                            <th style="width:170px">导入时间</th>
                            <th style="width:100px" excel="none">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-if="items.totalPage == 0"><td colspan="100" class="text-center">暂无记录</td></tr>
                        <tr ng-repeat-start="item in items.list" ng-if="!item.edit">
                            <td class="text-center">{{$index + 1+items.pageSize*(items.currentPage-1)}}</td>
                            <td>{{item.company}}</td>
                            <td>{{item.name}}</td>
                            <td>{{item.licensePlate}}</td>
                            <td>{{item.insuranceNo}}</td>
                            <td>{{item.amount|currency : '￥'}}</td>
                            <td>{{item.op|idToValue:adminList}}</td>
                            <td>{{item.optime| date : 'yyyy/MM/dd HH:mm:ss'}}</td>
                            <td  excel="none">
                                <button ng-if="hasAccess('modify')" onmouseover="tips('修改',this);" onmouseout="closeTip(this)" class="btn btn-default" ng-click="edit(item)" ><i class="glyphicon glyphicon-pencil" ></i></button>
                                <button ng-if="hasAccess('del')" onmouseover="tips('删除',this);" onmouseout="closeTip(this)" class="btn btn-danger" ng-click="del(item)"><i class="glyphicon glyphicon-trash" ></i></button>
                            </td>
                        </tr>
                        <tr ng-repeat-end ng-if="item.edit" ng-form name="form" novalidate>
                            <td class="text-center">{{$index + 1+items.pageSize*(items.currentPage-1)}}</td>
                            <td><input type="text" class="form-control" ng-model="item.copy.company" /></td>
                            <td><input type="text" class="form-control" required name="name" ng-model="item.copy.name" /></td>
                            <td><input type="text" class="form-control" required name="licensePlate" ng-model="item.copy.licensePlate" /></td>
                            <td><input type="text" class="form-control" required name="insuranceNo" ng-model="item.copy.insuranceNo"
                                       api='/bill/checkUnique' ensure_unique='insuranceNo' id={{item.copy.id}}
                                       onmouseover="$(this).hasClass('ng-invalid-unique')?(tips('相同保单号已存在!',this)):'';" onmouseout="closeTip(this)"
                                    /></td>
                            <td><input type="text" class="form-control" required name="amount" ng-model="item.copy.amount" /></td>
                            <td>{{item.optime| date : 'yyyy/MM/dd HH:mm:ss'}}</td>
                            <td  excel="none">
                                <button class="btn btn-primary" ng-click="save(form,item)" onmouseover="tips('保存',this);" onmouseout="closeTip(this)"><i class="glyphicon glyphicon-floppy-disk" ></i></button>
                                <button class="btn btn-default" ng-click="cancel(item)" onmouseover="tips('取消',this);" onmouseout="closeTip(this)"><i class="glyphicon glyphicon-ban-circle" ></i></button>
                            </td>
                        </tr>
                        <tr></tr>
                        </tbody>
                    </table>
                    <div class="page-footer clearfix">
                        <ng-include src="'/pager.html'"></ng-include>
                    </div>

                    <h3 class="h3" ng-if="statics">台账单上传：成功<em class="text-success">{{statics.saveNum}}</em>；重复<em class="text-info">{{statics.alreadyExistNum}}</em>；
                        金额为空<em class="text-danger">{{statics.wrongNum}}</em>；
                        不一致<em class="text-danger">{{statics.nomatchNum}}</em></h3>

                </uib-tab>
                <uib-tab heading="错误日志"  ng-if="hasAccess('errorTab')" >
                    <div ng-controller="wrongbillCtl">
                        <div class="navbar-form clearfix">
                            <div class="form-inline" style="margin-top: 5px">
                                <div class="form-group">
                                    <label>内勤</label>
                                    <select ng-model="search.op" class="form-control" ng-options="o.id as o.account for o in adminList|filter:{roleId:3}" style="width:120px;">
                                        <option value="">--请选择--</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>被保险人</label>
                                    <input type="text" ng-model="search.name" class="form-control" style="width:120px;"/>
                                </div>
                                <div class="form-group">
                                    <label>车牌</label>
                                    <input type="text" ng-model="search.licensePlate" class="form-control" style="width:120px;"/>
                                </div>

                               <!-- <div class="form-group ">
                                    <label>导入时间</label>
                                    <input class="form-control wdate" id="fromDate"  readOnly=true onchange=""
                                           onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:&quot;#F{$('#toDate').val()||'%y-%M-%d'}&quot;})" ng-model="search.fromDate"></input>
                                    <label>-</label>
                                    <input class="form-control wdate" id="toDate"  readOnly=true onchange=""
                                           onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:&quot;#F{$('#fromDate').val()}&quot;,maxDate:'%y-%M-%d'})" ng-model="search.toDate"></input>
                                </div>-->
                                <button class="btn btn-primary" ng-if="hasAccess('query')" ng-click="find(1)" >查询</button>
                                <button class="btn btn-danger" ng-if="hasAccess('clear')" ng-click="truncateWrong()"  >清空</button>
                            </div>
                        </div>
                        <table class="table table-bordered table-striped table-hover" >
                            <thead class="title">
                            <tr>
                                <th class="text-center" style="width:30px">NO</th>
                                <th style="width:85px">保险公司</th>
                                <th style="width:135px">被保险人</th>
                                <th style="width:95px">车牌</th>
                                <th >保单号</th>
                                <th style="width:110px">金额</th>
                                <th style="width:100px">导入者</th>
                                <th style="width:170px">导入时间</th>
                                <th style="width:100px" excel="none">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-if="items.totalPage == 0"><td colspan="100" class="text-center">无不一致记录</td></tr>
                            <tr ng-repeat-start="bill in items.list">
                                <td class="text-center">{{$index + 1}}</td>
                                <td>{{bill.company}}</td>
                                <td ng-class="{'bg-danger':bill.errorType==1}">{{bill.name}}</td>
                                <td ng-class="{'bg-danger':bill.errorType==2}">{{bill.licensePlate}}</td>
                                <td>{{bill.insuranceNo}}</td>
                                <td ng-class="{'bg-danger':bill.errorType==3||bill.errorType==4}">{{bill.amount|currency : '￥'}}</td>
                                <td>{{bill.op|idToValue:adminList}}</td>
                                <td>{{bill.optime| date : 'yyyy/MM/dd HH:mm:ss'}}</td>
                                <td excel="none">
                                    <button class="btn btn-default" ng-class="{active:bill.showRec}" ng-click="compare(bill)" onmouseover="tips('比较',this);" onmouseout="closeTip(this)"><i class="glyphicon glyphicon-sunglasses" ></i></button>
                                    <button class="btn btn-danger" ng-show="bill.status!=1" ng-click="changeStatus(bill,1)" onmouseover="tips('未处理',this);" onmouseout="closeTip(this)"><i class="glyphicon glyphicon-question-sign" ></i></button>
                                    <button class="btn btn-success" ng-show="bill.status==1" ng-click="changeStatus(bill,2)" onmouseover="tips('已处理',this);" onmouseout="closeTip(this)"><i class="glyphicon glyphicon-ok" ></i></button>
                                    <button ng-if="hasAccess('del')" onmouseover="tips('删除',this);" onmouseout="closeTip(this)" class="btn btn-danger" ng-click="del(bill)"><i class="glyphicon glyphicon-trash" ></i></button>
                                </td>
                            </tr>
                            <tr ng-repeat-end class="info" ng-if="bill.showRec">
                                <td class="text-center"></td>
                                <td>{{bill.rec.company}}</td>
                                <td ng-class="{'bg-success':bill.errorType==1}">{{bill.rec.name}}</td>
                                <td ng-class="{'bg-success':bill.errorType==2}">{{bill.rec.licensePlate}}</td>
                                <td>{{bill.rec.insuranceNo}}</td>
                                <td ng-class="{'bg-success':bill.errorType==3||bill.errorType==4}">{{bill.rec.amount|currency : '￥'}}</td>
                                <td>{{bill.rec.op|idToValue:adminList}}</td>
                                <td>{{bill.rec.optime| date : 'yyyy/MM/dd HH:mm:ss'}}</td>
                                <td excel="none">
                                </td>
                            </tr>

                            <tr></tr>
                            </tbody>
                        </table>
                        <div class="page-footer clearfix">
                            <ng-include src="'/pager.html'"></ng-include>
                        </div>
                    </div>
                </uib-tab>
                <uib-tab heading="对账模式" ng-if="hasAccess('campareTab')">
                    <div class="form-inline navbar-form">
                        <div class="input-group">
                            <input type="text" class="form-control" readonly="readonly" placeholder="上传台帐"
                                   name="totalBillName" required ng-model="bills.totalBillName" />
								  <span class="input-group-btn">
									<button  class="btn btn-default" ng-click="uploadTotalBill()" ng-class="{'btn-success':bills.totalBillName}" ><i class='glyphicon glyphicon-upload'></i></button>
								  </span>
                        </div>
                        <div class="input-group">
                            <input type="text" class="form-control" readonly="readonly" placeholder="上传手续费清单"
                                   name="subBillName" required ng-model="bills.subBillName" />
								  <span class="input-group-btn">
									<button  class="btn btn-default" ng-click="uploadSubBill()" ng-class="{'btn-success':bills.subBillName}" ><i class='glyphicon glyphicon-upload'></i></button>
								  </span>
                        </div>
                        <button class="btn btn-primary" ng-click="compareBills()">生成比较结果</button>
                    </div>

                    <table class="table table-bordered table-striped table-hover" >
                        <caption class="h3">保单比较结果：上传的手续费清单中<em class="text-danger">{{unFinished.length?unFinished.length:'?'}}</em>条记录未在台帐中找到一致记录</caption>
                        <thead class="title">
                        <tr>
                            <th class="text-center" style="width:30px">NO</th>
                            <th style="width:135px">被保险人</th>
                            <th style="width:95px">车牌</th>
                            <th >保单号</th>
                            <th style="width:110px">金额</th>
                            <th style="width:170px">比较时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-if="unFinished.length == 0"><td colspan="100" class="text-center">暂无结果</td></tr>
                        <tr ng-repeat="bill in unFinished">
                            <td class="text-center">{{$index + 1}}</td>
                            <td >{{bill.name}}</td>
                            <td>{{bill.licensePlate}}</td>
                            <td>{{bill.insuranceNo}}</td>
                            <td>{{bill.amount|currency : '￥'}}</td>
                            <td>{{bill.optime| date : 'yyyy/MM/dd HH:mm:ss'}}</td>
                        </tr>

                        </tbody>
                    </table>
                </uib-tab>
            </uib-tabset>
        </div>
        <div class="panel-footer text-center" style="position: absolute;bottom:0;width: 100%; ">Copyright ©2017 Hello.FENG </div>
    </div>
</body>
<script type="text/javascript" src="vendor/jquery.min.js"></script>
<script type="text/javascript" src="vendor/datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="vendor/ajaxfileupload.js"></script>
<script type="text/javascript" src="vendor/exportExcel.js"></script>
<script type="text/javascript" src="vendor/layer/layer.js"></script>
<script type="text/javascript" src="vendor/angular1.5.11/angular.min.js"></script>
<script type="text/javascript" src="vendor/angular1.5.11/ui-bootstrap-tpls.min.js"></script>
<script>
    document.write( " <script src='js/billCtl.js?rnd= " + Math.random() + " '></s"+"cript> " )
</script>

</html>